package com.gurun.codes.views.bind_adapter;

import android.databinding.BindingAdapter;
import android.graphics.Color;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.gurun.codes.R;

public class ImageViewBindingAdapter {

    @BindingAdapter({"imageurl"})
    public static void setSrc(ImageView view, String imageurl) {
        if (view != null) {
            Glide.with(view.getContext())
                    .load(imageurl)
                    .into(view);
        }
    }

    @BindingAdapter({"onlineimageRes","onalarmImageRes"})
    public static void setonlineres(ImageView view, String status,int alarmFlag) {
        if (view != null) {
            if (alarmFlag == 1){
                view.setImageResource(R.drawable.shape_device_alarm);
            }else{
                if ("设备离线".equals(status)) {
                    view.setImageResource(R.drawable.shape_device_offline);
                } else {
                    view.setImageResource(R.drawable.shape_device_online);
                }
            }
        }
    }
}
